/**
 * Copyright (C) 2011-2012 GreenSoft S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ar.com.greensoft.neosystem.user;

import java.util.List;

import javax.annotation.ManagedBean;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import ar.com.greensoft.jeecommons.web.jsf.export.ColumnValueMapper;
import ar.com.greensoft.jeecommons.web.jsf.export.ExportColInfo;
import ar.com.greensoft.neosystem.dao.GenericDao;
import ar.com.greensoft.neosystem.dao.ProvinciaDao;
import ar.com.greensoft.neosystem.model.address.Pais;
import ar.com.greensoft.neosystem.model.address.Provincia;
import ar.com.greensoft.neosystem.search.SearchFilter;
import ar.com.greensoft.neosystem.search.address.ProvinciaSearchFilter;

/**
 *
 * @author Jorge E. Villaverde
 * @since 1.0.0
 * @version 1.0.0
 */
@ManagedBean
@SessionScoped
@Named
public class ProvinciaBean extends AbstractLongIdUserRoleCrudFacedeBean<Provincia>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7971149685011287365L;
	private static final String ENTITY_PREFIX = "direccion/provincia";
	private static final String ENTITY_MSG_PREFIX = "direccionProvincia";
	
	@Inject
	private ProvinciaDao dao;
	
	private Pais pais;

	@Override
	protected GenericDao<Provincia, Long> getDao() {
		return dao;
	}

	@Override
	protected Provincia newEntity() {
		Provincia entity = new Provincia();
		entity.setPais(pais);
		return entity;
	}

	@Override
	protected String entityPrefix() {
		return ENTITY_PREFIX;
	}

	@Override
	protected String getEntityMessagePrefix(){
		return ENTITY_MSG_PREFIX;
	}

	@Override
	protected SearchFilter createSearchFilter() {
		return new ProvinciaSearchFilter();
	}

	@Override
	public ProvinciaSearchFilter getSearchFilter(){
		return (ProvinciaSearchFilter)super.getSearchFilter();
	}
	
	public Pais getPais() {
		return pais;
	}

	public void setPais(Pais pais) {
		this.pais = pais;
	}

	@Override
	protected String getEntityName(Provincia entity) {
		return entity.getName();
	}

	@Override
	protected Provincia findEntityByName(String entityName) {
		return null;
	}
	
	protected Provincia findEntity(Provincia entity){
		if(entity == null)
			return null;
		return dao.findByPaisName(entity.getPais(), entity.getName());
	}

	@Override
	protected List<ExportColInfo> getExportColInfoList() {
		return null;
	}

	@Override
	protected ColumnValueMapper<Provincia> getColumnValueMapper() {
		return null;
	}

}
